Repository navigation
Add Make-native test target across all examples - #445
Merged
Merged
Conversation
Closes the testing half of the Make-build CI work that was deferred from PR1 (ROCm#442). With this commit `make test` from the repo root builds and runs every leaf example that registered an add_test in CMake, matching the existing CMake/CTest coverage. CI just orchestrates; all test command/args/timeout logic lives in the Makefiles. Per mentor (@zichguan-amd) design: - Each leaf Makefile gains a `test:` target depending on its build target. Default invocation: `./$(EXAMPLE) $(TEST_ARGS)`. Most leaves set no args. - bfs sets `TEST_ARGS := graph4096.txt` (mirrors its CMake add_test). - Leaves whose CMakeLists has no add_test() get an empty no-op `test:` (HIP-Basic/{opengl_interop,vulkan_interop,static_device_library} and Libraries/MIVisionX/{canny,mv_objdetect,opencv_orb} and three rocDecode examples that don't register). - REQUIRED_DEPS leaves (~28) extend their existing SKIP_BUILD `else` no-op block with `test:` alongside `all:`/`clean:`. Cascade: each parent Makefile (root + ~80 intermediates) declares `SKIP_FROM_TEST :=` and: test: TARGET=test test: $(filter-out $(SKIP_FROM_TEST),$(EXAMPLES)) So `make test` cascades through the tree, skipping any subdirs the parent has explicitly excluded. `Libraries/rocDecode/Makefile` populates `SKIP_FROM_TEST := $(EXAMPLES)`: all rocDecode examples need test data (videos under `$(ROCM_PATH)/share/rocdecode/`) that ctest currently guards behind `if(EXISTS …)` checks. Encoding that conditional logic in Make is doable but noisy; deferring to a follow-up. The leaf rocDecode Makefiles still have working `test:` targets so they can be run standalone via `cd Libraries/rocDecode/<example> && make test`. Out of scope (per plan, can land later): - Per-GPU-arch test skipping (`generate_skip_tests.py` is still used by the existing ctest step; PR2's per-directory `SKIP_FROM_TEST` is coarser). - Reduction tutorial gtest binaries (`Tutorials/reduction/test/*.hip`) — no Makefile builds them today. Workflow: adds `Makefile test` step after the existing test steps and `Upload Makefile test logs` artifact upload. Both gated with `if: !cancelled()` to mirror the rest of the test-side steps. Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
Same conversion as the rocDecode leaves: replace literal `-lstdc++fs`
with `$(CXX_FS_LIB)` and include `Common/find_filesystem.mk`. Keeps
all leaves consistent and surfaces what's actually needed via probe
rather than blanket-adding the flag everywhere.
Affected:
- Applications/fdtd
- HIP-Basic/module_api
- HIP-Doc/.../linker_apis_file
- Libraries/rocJPEG/{rocjpeg_decode, rocjpeg_decode_batched, rocjpeg_decode_perf}
- Libraries/rocProfiler-SDK/{api_buffered_tracing, code_object_isa_decode,
code_object_tracing, external_correlation_id_request, intercept_table,
openmp_target, pc_sampling, thread_trace,
counter_collection/{buffer, buffer_device_serialization, device_profiling,
device_profiling_sync, print_functional_counters}}
These currently work on all three CI distros (libstdc++fs is available
as either a stub or the real lib), so this is hygiene rather than a
bug fix. Aligns with the rocDecode probe conversion in the parent
Make-test-target commit.
Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
1. linker_apis_file/Makefile was missing COMMON_INCLUDE_DIR. The
prior hygiene cleanup (commit converting hard-coded -lstdc++fs to
the Common/find_filesystem.mk probe) added an `include
$(COMMON_INCLUDE_DIR)/find_filesystem.mk` line, but this leaf
never defined COMMON_INCLUDE_DIR (its example doesn't reference
any common headers). The include silently failed, make exited 2,
parent cascade reported `Error 2`. Add the missing definition.
2. Workflow "Makefile test" step now passes
HIP_ARCHITECTURES="${{ matrix.gpu_config.gpu_target }}" so leaf
Makefiles using it (e.g. assembly_to_executable's multi-arch
build) target only the matrix's arch instead of falling back
to their full hardcoded default list. Without this, the
`--cuda-device-only -S --offload-arch=<X>` recipe collided
with CI's HIPCC_COMPILE_FLAGS_APPEND=--offload-arch=gfx1100
env, producing two `--offload-arch` flags and:
clang++: error: cannot specify -o when generating multiple
output files
Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
sshi-amd
force-pushed
the
makefiles-testing-pr2
branch
from
April 24, 2026 16:16
e113c8c to
0c23b54
Compare
The PR2 parent-Makefile updater script regex didn't account for
trailing whitespace on the last line of the EXAMPLES continuation
in the original (` graph_creation \n`), so the regex stopped
matching after `graph_capture \` and inserted SKIP_FROM_TEST in
the middle of the multi-line assignment. Result:
EXAMPLES := \
graph_capture \
SKIP_FROM_TEST :=
graph_creation ← orphaned, "missing separator" at line 27
Restore the continuation so EXAMPLES contains both children.
HIP-Graphs is the only Makefile that hit this — verified with
`make -n` from each parent: 0 syntax errors tree-wide.
Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
zichguan-amd
approved these changes
Apr 24, 2026
zichguan-amd
left a comment
Collaborator
There was a problem hiding this comment.
LGTM. TEST_ARGS might need to be aligned with ctest, we can iterate on it later.
sshi-amd
marked this pull request as ready for review
April 24, 2026 18:57
For the 7 rocDecode leaves whose CMake `add_test` actually passes positional args, replace the bare `./$(EXAMPLE) $(TEST_ARGS)` template with custom recipes that mirror ctest exactly: - Single-variant leaves (rocdec_decode, video_decode_mem, video_decode_perf, video_decode_batch): probe `[ -e <test data> ]` and skip cleanly with a "Skipping (not found)" message if the ctest data path doesn't exist, mirroring CMake's `if(EXISTS …)` register-time guard. Otherwise run the binary with the same `-i <path>` (and `-t 2` for batch) ctest passes. - Multi-variant leaves: ctest registers one test per codec. - video_decode → HEVC, AVC, AV1, VP9 mp4 - video_decode_raw → HEVC, AVC, AV1, VP9 raw bitstreams - video_decode_rgb → default + `-resize 640x360` Recipe loops through every variant ctest registers, runs each one whose input file exists, skips the rest, and returns the worst exit code (so a failing AVC doesn't mask a failing AV1 the way fail-fast `&&` would). Per @zichguan-amd review feedback that "TEST_ARGS might need to be aligned with ctest". TEST_ARGS as a single-string knob doesn't map cleanly to multi-variant ctest tests; a custom recipe with `$(ROCM_PATH)` deferred-expanded at use time is the closer parity. These 7 leaves are still parent-skipped via Libraries/rocDecode/ Makefile's `SKIP_FROM_TEST := $(EXAMPLES)` so the root `make test` cascade doesn't try them in CI. They become useful when run standalone (`cd Libraries/rocDecode/<example> && make test`) on a machine with the rocDecode test data installed under `$(ROCM_PATH)/share/rocdecode/`. README also gains a short paragraph documenting the env / CLI override pattern (`TEST_ARGS=foo make test`). Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
markdownlint-cli2 MD014/commands-show-output was firing on the two TEST_ARGS override examples introduced in the prior commit: $ make test TEST_ARGS="--size=8192 --verbose" $ TEST_ARGS="-i /path/to/video.mp4" make test The `$` prompt prefix is meant for examples that show command output; for bare invocations it's just noise that markdownlint flags. Drop it. The earlier `$` prefixes (lines 56-58, the git/cd/configure chain) are inside bullet list items and aren't flagged. Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Closes the testing half of the Make-build CI work that was deferred from #442. With this PR
make testfrom the repo root builds and runs every leaf example that registered anadd_testin CMake, matching the existing CMake/CTest coverage. CI just orchestrates; all test command/args/timeout logic lives in the Makefiles.This PR is stacked on top of #442 — its diff against
amd-stagingwill look much smaller once #442 lands.Technical Details
Leaf Makefile
test:targetEvery leaf Makefile gains a
test:target depending on its build target. Default invocation:TEST_ARGSis empty by default.HIP-Doc/Tutorials/Programming-Patterns/bfs/MakefilesetsTEST_ARGS := graph4096.txtto mirror its CMakeadd_test.add_test()get an empty no-optest:(e.g.HIP-Basic/{opengl_interop, vulkan_interop, static_device_library},Libraries/MIVisionX/{canny, mv_objdetect, opencv_orb}, three rocDecode examples that don't register).elseno-op block withtest:alongsideall:/clean:.Parent Makefile cascade with per-parent skip list
Every parent Makefile (root + ~80 intermediates) declares
SKIP_FROM_TEST :=and:So
make testcascades through the tree, skipping any subdirs the parent has explicitly excluded.Libraries/rocDecode/MakefilepopulatesSKIP_FROM_TEST := $(EXAMPLES): all rocDecode examples need test data (videos under$(ROCM_PATH)/share/rocdecode/) that ctest currently guards behindif(EXISTS …)checks. Encoding that conditional logic in Make is doable but noisy; deferring to a follow-up. The leaf rocDecode Makefiles still have workingtest:targets so they can be run standalone viacd Libraries/rocDecode/<example> && make test.Common/find_filesystem.mkcleanupThe PR also converts the 19 remaining leaves with hard-coded
-lstdc++fsto use the sameCommon/find_filesystem.mkprobe introduced in #442 for the rocDecode leaves. After this, no leaf Makefile in the tree has a literal-lstdc++fs. Hygiene, not a bug fix — they currently work on all three CI distros.CI workflow
Adds
Makefile teststep after the existing test steps andUpload Makefile test logsartifact upload. Both gated withif: !cancelled()to mirror the rest of the test-side steps.Out of scope (potential follow-ups)
generate_skip_tests.pyis still used by the existing ctest step; PR2's per-directorySKIP_FROM_TESTis coarser.Tutorials/reduction/test/*.hip) — no Makefile builds them today.if(EXISTS ${ROCDECODE_TEST_VIDEO_HEVC})pattern) — currently the entire rocDecode subtree is skipped at parent level.Test Plan
bitonic_sort(bare run),bfs(withTEST_ARGS), root cascade dry-run reaches every leaf,Libraries/rocDecodecascade correctly does nothing.Added/Updated documentation?
Included Visual Studio files?
Submission Checklist
SKIP_FROM_TEST)